<template>
	<view >
		<view v-if="isloaded">
			<slot></slot>
		</view>
	</view>
</template>

<script>
	export default {
		name:"loading-gurad",
		props:{
			asyncLoadFunc : {
				type: Function,
				defualt:null
			}
		},
		async beforeCreate() {
			if(this.asyncLoadFunc)
			{
				console.log('正在疯狂加载')
				console.log(this.asyncLoadFunc)
				
				uni.showLoading({
					title:'正在疯狂加载'
				})

				await this.asyncLoadFunc()
				this.isloaded = true
				uni.hideLoading()
				console.log('加载完毕')
				console.log(this.isloaded)
			}else{
				// this.isloaded = true
			}
		},
		data() {
			return {
				isloaded:false
			};
		}
	}
</script>

<style>

</style>